<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <title>分享</title>
    <link rel="stylesheet" href="../css/aui.css">
    <link rel="stylesheet" href="../css/common.css">
    <script type="text/javascript" src="../../script/api.js"></script>
    <script language="JavaScript" src="../../script/vue.js"></script>
    <script language="JavaScript" src="../../script/common.js"></script>
    <style>
        html {
            width: 100%;
            height: 100%;
            background: transparent;
        }

        body {
            background: rgba(0, 0, 0, 0.4);
            width: 100%;
            height: 100%;
        }

        .floatbox {
            position: absolute;
            text-align: center;
            background: #fff;
            width: 100%;
            bottom: 0;
            left:0;
        }

        .floatheader {
            height: 40px;
            line-height: 40px;
            font-size: 14px;
            color: #999;
            text-align: left;
            margin-left: 20px;
        }

        .floatbody {
            border-bottom: 1px solid #D0D2D6;
        }


        .floatfooter {
            height: 40px;
            line-height: 40px;
            font-size: 18px;
        }

        .row {
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            width: 100%;
        }

        .col {
            -webkit-box-flex: 1;
            -webkit-flex: 1;
            flex: 1;
            padding: 10px;
        }

        .col img {
            width: 3rem;
            display: block;
            margin: 0 auto;
        }

        .col span {
            font-size: 12px;
            padding-top: 10px;
        }

        .btn-hov {
            background-color: #D1D4D7;
        }
    </style>
</head>

<body  onclick="fnClose()">
    <div class="floatbox" id="sharebox" >
        <div class="floatheader">分享(演示版不开放)</div>
        <div class="floatbody" @click.stop>
            <div class="row">
                <div class="col" tapmode="btn-hov"  @click="shareit('wx_session')">
                    <img src="../../image/share/share_to_icon_wx.png" alt="">
                    <span>微信好友</span>
                </div>
                <div class="col" tapmode="btn-hov"  @click="shareit('wx_timeline')">
                    <img src="../../image/share/share_to_icon_wxq.png" alt="">
                    <span>微信朋友圈</span>
                </div>
                <!-- <div class="col" tapmode="btn-hov" @click="shareit('qq')">
                        <img src="../image/share/share_to_icon_qq.png" alt="">
                        <span>QQ</span>
                    </div> -->

            </div>

        </div>
    </div>
</body>
<script type="text/javascript">
    var pvm = new Vue({
        el: '#sharebox',
        data: {
            pagetype: 'productinfo',
            id: 0
        },
        methods: {
            shareit: function(platform) {
                $page.get_data('/api/share/getConfig', 'post', {
                        platform: platform,
                        pagetype: this.pagetype,
                        id: this.id
                    },
                    function(ret) {
                         var data = ret.data;
                        if (platform == "wx_session") {
                            pvm.sharewxsession(data);
                        } else if (platform == "wx_timeline") {
                            pvm.sharewxtimeline(data);
                        }
                    });
                console.log(platform);

            },
            sharewxsession: function(data) {
              $page.toast('演示版，不开放分享!');
              return;
                var wx = api.require('wx');
                wx.shareWebpage({
                    scene: 'session',
                    title: data.title,
                    description: data.description,
                    contentUrl: data.contentUrl
                }, function(ret, err) {
                  console.log(JSON.stringify(ret));
                    if (ret.status) {
                        $page.toast('分享成功!');
                    }else{
                      $page.toast("错误：code("+err.code+")");
                    }
                });
            },
            sharewxtimeline: function(data) {
              $page.toast('演示版，不开放分享!');
              return;
                var wx = api.require('wx');
                wx.shareWebpage({
                    scene: 'timeline',
                    title: data.title,
                    description: data.description,
                    contentUrl: data.contentUrl
                }, function(ret, err) {
                    if (ret.status) {
                        $page.toast('分享成功!');
                    }else{
                      $page.toast("错误：code("+err.code+")");
                    }
                });
            }

        }
    });


    function fnClose() {
        api.execScript({
            name: api.winName,
            script: 'openshare();'
        });
    }
    apiready = function() {
      var pageParam = api.pageParam;
      pvm.id = pageParam.id;
      pvm.pagetype = pageParam.pagetype;

    }
</script>

</html>
